#version 460
#extension GL_GOOGLE_include_directive : enable

#include "../../../../core/shader_color.h"
#include "../../../../core/shader_curve.h"

layout(points) in;
layout(points, max_vertices=64) out;





layout(location = 1) in VS_GS_VERTEX {
	uint vInstance;
}vertex_in[];


layout(location = 0) out vec4 gColor;
out gl_PerVertex {
	vec4	gl_Position;
	float	gl_PointSize;
};

//vec2 pos[4] = {vec2(10.0, 10.0), vec2(100.0, 10.0), vec2(10.0, 100.0), vec2(100.0, 100.0)};
void main(void){
	uint Instance = vertex_in[0].vInstance;
	
	S_CurvePoint s_curve = m_Curve[Instance];
	vec4 Color = f_glsl_buildColor(s_curve.ID_Color.y);
	


	vec4 v = vec4(s_curve.value, 0, 1);
	v.xy *= m_Scale;
	v.xy += m_Loc;
	v = mat_ProjecView * v;
	
	if (bool(s_curve.Select_Type.x & 1)) {
		gl_Position = v;
		gColor = Color * 4;
		gl_PointSize = 11.0;
		EmitVertex();
	}
	gl_Position = v;
	gColor = Color * 0.4;
	gl_PointSize = 8.0;
	EmitVertex();



	if(bool(s_curve.Select_Type.x)){
		v = vec4(s_curve.L_point, 0, 1);
		v.xy *= m_Scale;
		v.xy += m_Loc;
		v = mat_ProjecView * v;

		if (bool(s_curve.Select_Type.x & 2)) {
			gl_Position = v;
			gColor = Color * 4;
			gl_PointSize = 10.0;
			EmitVertex();
		}
		gl_Position = v;
		gColor = Color * 0.2;
		gl_PointSize = 6.0;
		EmitVertex();



		v = vec4(s_curve.R_point, 0, 1);
		v.xy *= m_Scale;
		v.xy += m_Loc;
		v = mat_ProjecView * v;

		if (bool(s_curve.Select_Type.x & 4)) {
			gl_Position = v;
			gColor = Color * 4;
			gl_PointSize = 10.0;
			EmitVertex();
		}
		gl_Position = v;
		gColor = Color * 0.2;
		gl_PointSize = 6.0;
		EmitVertex();
	}
	EndPrimitive();

}



 